package com.example.score.account;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author fsyj
 */
@NoArgsConstructor
@Data
public  class Account {
    protected String id;
    protected String account;
    protected String password;

    public Account(String account, String password) {
        if (account == null) {
            account = "";
        }
        if (password == null) {
            password = "";
        }
        this.account = account;
        this.password = password;
    }

    public boolean verify(String username, String passwd) {
        return this.account.equals(username) && this.password.equals(passwd);
    }

    @Override
    public String toString() {
        return "Account{" +
                "account='" + account + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Account account = (Account) o;
        return id.equals(account.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
